home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Help Me !
- Date: 23 Feb 1996 17:01:13 GMT
- Organization: OpenVision
- Message-ID: <4gkrsp$g18@spanky.pls.ov.com>
- References: <4geh23$e3u@newsbf02.news.aol.com>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article e3u@newsbf02.news.aol.com, mackboring@aol.com (MackBoring) writes:
- >I need to create a program to display a list of the first 1000 prime
- >integers (starting with 2) you need test only odd numbers and for
- >divisibilty with odd numbers
-
-
- Let's do a little thinking here. A prime number is not evenly divisable
- by any numbers except itself and one. Further, the only numbers necessary
- to test a prime number is other primes. Lastly, if you have tested with
- primes < test_number/2, then you need not test with greater primes as
- 2 is the smallest prime result possible. In fact, as you test with the
- samllest primes first, the largest necessary prime to test with is reduced
- accordingly. i.e. if you test with three and fail, then the largest prime
- to test with is < your test_number/3, and so forth. If you have tested with
- 2 and 3 (primes) do you see why you don't have to test with 6 (non-prime)?
-
- Fletcher.Glenn@ov.com
-
-
-